// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include <SDKDDKVer.h>

#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>


#define DEBUG
//#define MKNAPCB_DATA
//#define FDENABLE 
#define GAONLY
#define DUMMYGA
//#define NOCLUSTER
//#define REVERT
#define SHARE

//#define TESTONLY

//#define DIMENSIONS


#ifdef MKNAPCB_DATA
#define MAXCLASS		100
#define MAXDIMENSION	32
#define MAXITEMINCLASS	5
#define MAXTEST			30
#define ITEMPERCLASS	5
#else
#define NOCLUSTER
#define MAXCLASS		400
#define MAXDIMENSION	10
#define MAXITEMINCLASS	5
#define MAXTEST			13
#define ITEMPERCLASS	5

#endif
////// cluster
#define MAXCLUSTERSIZE 3

#ifdef WIN32
#define fopen fopen_s
#define fscanf fscanf_s
#endif	//WIN32

#define FIRSTPOP 0


// TODO: reference additional headers your program requires here
#include "NodeTable.h"
#include "Chro.h"

void sort(int* arr,int len);
void fsort(float* src, int len);
int combination(int n, int r);
void setTime(time_t* in);
time_t getTimeGap(time_t* in);

#define JERROR(xx) printf("ERROR : %" #xx "  Func :%s line :%d\r\n", __FUNCTION__, __LINE__)
#define JWARNING(xx) printf("WARNING : %"#xx "  Func :%s line :%d\r\n", __FUNCTION__, __LINE__)

#define DEBUG2
#ifdef DEBUG2
#define JDPRINT(var) printf(" "#var " is : %d \r\n", var); 
#define JDFPRINT(var) fprintf(fp," "#var " is : %d \r\n", var); 
#define JFPRINT(var) printf(" "#var " is : %f \r\n", var); 
#define JLFPRINT(var) printf(" "#var " is : %lf \r\n", var); 
#define JSPRINT(var) printf(" "#var " is : %s \r\n", var); 
#else
#define JDPRINT(var)  
#define JFPRINT(var)  
#define JLFPRINT(var) 
#define JSPRINT(var) 

#endif


#define __TUNING__ 0
#define DEBUG_LOW 1
#define DEBUG_HIGH 1
#define DEBUG_DETAIL 1

#define RESULTOUT stdout

#define DBFR


 class Glovar
{
private:
	Glovar();
	~Glovar();
	static Glovar* gv;
public:
	static Glovar* GetGlovar();

	void PrintEnv(FILE* fp);
	void Log(char* buf);
	void Log(void* ch0);
	void LogFlush();

	void Log2(char* buf);
	void Log2(void* ch0);
	void LogFlush2();

	bool CheckRev();

	char filename[1024];
	bool isFirst;
	int maxGen;
	int popSize;
	int testSize;
	int procID;
	double g_f;
	bool bLog;
	bool bLog2;
	FILE* fplog;
	FILE* fplog2;

	bool bRev;
	int nRevCount;
	int maxSametop;
};